package com.sitanyun.merchant.guide.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sitanyun.merchant.guide.R;
import com.sitanyun.merchant.guide.bean.EnterShopDialsBean;

/**
 * Created by jzl
 * on 2022/1/8.
 * 消息列表
 */
public class ShopEnterAdapter extends BaseQuickAdapter<EnterShopDialsBean.DataBean.RecordsBean, BaseViewHolder> {
  private String count;

    public ShopEnterAdapter(Context context,String s) {
        super(R.layout.shopenter_item);
        this.mContext = context;
        this.count=s;
    }

    @Override
    protected void convert(BaseViewHolder helper, EnterShopDialsBean.DataBean.RecordsBean item) {
        TextView tv_sharsmsg =  helper.getView(R.id.tv_sharsmsg);
        TextView shopentershar =  helper.getView(R.id.shopenter_shar);
      if (count.equals("1")){
          tv_sharsmsg.setText("分享次数： ");
          shopentershar.setText(item.getShareCnt() + "");
      }else if (count.equals("2")){
          tv_sharsmsg.setText("浏览次数： ");
          shopentershar.setText(item.getBrowseCnt() + "");
      }else {
          tv_sharsmsg.setText("浏览用户数： ");
          shopentershar.setText(item.getBrowseCust() + "");
      }

        TextView shopentername =  helper.getView(R.id.shopenter_name);
        TextView shopenternums =  helper.getView(R.id.shopenter_num);
        ImageView shopenterimgs =  helper.getView(R.id.shopenter_imgs);
        ImageView shopenterimg =  helper.getView(R.id.shopenter_img);
        View shopenterview =  helper.getView(R.id.shop_view);
        View shopenterviews =  helper.getView(R.id.shop_views);

      if (item.getStaffName()==null){
          shopentername.setText("访客");
      }else {
          shopentername.setText(item.getStaffName() + "");
      }


        Glide.with(mContext).load(item.getAvatar()).error(R.mipmap.cimg).into(shopenterimg);
        if (helper.getPosition() == 0) {
            shopenterview.setVisibility(View.VISIBLE);
            shopenterviews.setVisibility(View.GONE);
        } else {
            shopenterview.setVisibility(View.GONE);
            shopenterviews.setVisibility(View.VISIBLE);
        }
        if (helper.getPosition() == 0) {
            shopenternums.setVisibility(View.GONE);
            shopenterimgs.setVisibility(View.VISIBLE);
            Glide.with(mContext).load(R.mipmap.one).into(shopenterimgs);

        } else if (helper.getPosition() == 1) {
            shopenternums.setVisibility(View.GONE);
            shopenterimgs.setVisibility(View.VISIBLE);
            Glide.with(mContext).load(R.mipmap.two).into(shopenterimgs);
        } else if (helper.getPosition() == 2) {
            shopenternums.setVisibility(View.GONE);
            shopenterimgs.setVisibility(View.VISIBLE);
            Glide.with(mContext).load(R.mipmap.three).into(shopenterimgs);
        } else {
            shopenternums.setVisibility(View.VISIBLE);
            shopenterimgs.setVisibility(View.GONE);
            String num = helper.getPosition()+"";
            int a = Integer.parseInt(num);
            int b = a + 1;
            String s = Integer.toString(b);
            shopenternums.setText(s + "");
        }
    }
}